class Foo(object):

    def __init__(self):
        self.name = "boo"

    def __getattr__(self, item):
        print("调用__getattr__了", item)

    def __setattr__(self, key, value):
        print("调用__setattr__方法了", key, value)

    def __delattr__(self, item):
        print("调用__delattr__", item)


foo = Foo()
ret = foo.xxx  # 输出     调用__getattr__了
foo.age = 18  # 调用__setattr__方法了
del foo.age  # 输出  调用__delattr__
"""
调用__setattr__方法了 name boo
调用__getattr__了 xxx
调用__setattr__方法了 age 18
调用__delattr__ age
"""